019590e7-16c5-7a98-9e63-aa8aa96fb9c9
Tuist Logo

Swift Stories

View in web browser

Featured work: Marcel

#2 - Jan 23, 2025

The power of extensibility in Swift apps

Welcome to issue 2!

The software we build serves a diverse world with varying needs across people and organizations. Creating solutions that cater to everyone's requirements can introduce complexity into our products. This is where extensibility comes in – making common tasks straightforward while keeping everything else possible.

To tackle this challenge, we first need to identify what's core to our app's domain and where extensibility points lie. Take GitHub Actions as an example: while build environments and standard automation formats are core elements, individual steps can be extended through first and third-party code. Similarly, in the Swift ecosystem, SPM handles package graph definition and interpretation at its core, while allowing developers to share and extend functionality through build-tool plugins.

Consider how the Swift compiler works within Xcode's build system – it freezes your app's static shape into a binary. While content might change, the app's capabilities reflect what's written in code or defined in a SwiftUI tree. But what if we could tell the compiler to resolve certain aspects at runtime? While not the default approach, it's entirely feasible.

The simplest form of extensibility is declarative. You define and parse a schema, then use it to adjust the app. This could be anything from themes (defined by you, users, or a community) to dropdown menu actions or UI directives – similar to backend-driven UI approaches some companies employ. For instance, Alexander Weiß created swiftui-theming, enabling not just predefined theme selection but potentially supporting a community-driven theme ecosystem.

As needs evolve, you might want to offer more advanced customization options, similar to Raycast or VSCode extensions. This might include letting developers customize your app's business logic. The first step is identifying extension points – what exactly are people extending? Your business logic may need adaptation to interface with external code components. The nature of this contract depends on your app's specific needs. Swift build-tool plugins demonstrate this by running at specific points during compilation, such as executing SwiftLint checks.

Technology choice comes next. The simplest approach uses spawned executables for communication – this is how Swift Macros work under the hood. While functional, debugging can be challenging. Raycast took an innovative approach, detailed in their blog post, by adopting NodeJS as their extension runtime. This gives developers access to the vast NPM package ecosystem, though it requires careful consideration of security through their review process.

For those seeking alternatives that leverage Swift, WebAssembly (WASM) and specifically SwiftWasm offer promising solutions. The PointFree team has explored this for frontend development, and discussions are ongoing about its potential use in Swift Macros. WASM's built-in security model provides natural boundaries for extension capabilities while maintaining the flexibility developers need.

Extensibility in Swift apps remains an exciting frontier with tremendous potential for customization and adaptation. We're eager to see more apps like Raycast drawing inspiration from web ecosystems while embracing native development. Imagine more applications like Obsidian, VSCode, or Slack – but built natively, supported by rich plugin ecosystems that enhance our daily experience.


Tools & sites

CCL

A Categorical Configuration Language

If you thought Pkl would be the definitive configuration language, let us tell you that there's still space to create something more minimalist, and that's what CCL is all about.

Siprep

A static analyzer for your Swift code

Thanks to this tool by Paul Hudson, you can build your own tools based on static code analysis, like explicitDependencyImportCheck by Konstantinos Nikoloutsos to catch implicit imports.

Rotato

3D mockup images and movies in minutes

Through this stunning mockup by Marcel, we discovered this swiss-knife tool for creating mockups. You might want to use it to make your app look even more professional.

SRCL

Terminal UI across terminals, web, and desktop

SRCL is a React library that allows building UIs with the look & feel of terminals, not just for the web but also for desktop and mobile applications. Imagine porting that idea to Swift with cross-platform Swift.

Zag

Powering UI components with finite state machines

Implementing accessible components that follow best practices can be a daunting task. Zag takes care of that for the web, so it can be useful when building your Swift on the Server apps. Or maybe you can take inspiration from it to build a similar solution for SwiftUI.


Worthy Five: Natan Rolnik

Natan Rolnik is an Apple platforms developer at Monday.com, where he works on the iOS and macOS apps. He is also the author of the Swift Toolkit – a blog and a podcast about using Swift to craft developer tools.

Natan Rolnik

An app worth installing:

NYT Games. In times where our attention is drained by infinite and useless social media content (which I like to call junk food for the brain), it's great to "exercise" the brain with different challenging word puzzles, especially if it's not your mother tongue. I don't miss a day of Wordle, Connections, Spelling Bee, Strands, and Crosswords.


An open-source project worth checking out:

I’ve been playing around with SwiftCloud, by Andrew Barba. It is a tool that allows you to define, using Swift, your cloud infrastructure - servers, CDNs, functions, and more. It actually reminds me of Tuist in some ways! I definitely recommend checking it out.


A developer tool worth using:

Git Tower has been my preferred way of using Git for almost a decade. Its design and functionality are top notch, and one relatively recent addition is my favorite: Undo (Cmd + Z) for any git operation.


A developer worth following:

The folks at PointFree push the limits of Swift in my opinion, and every time I watch an episode, it blows my mind. It doesn’t matter which area they touch, be it parsing, architecture, multi platform and Wasm, I always learn something new.


A book worth reading:

Bad Blood. It's one of the best books I've read in the last few years. It tells the crazy story of a startup in the medical industry, Theranos, and its founder, Elizabeth Holmes. It’s written by the journalist who investigated the story and revealed the “institutionalized scam” that Elizabeth and her partner were committing. The saying “The devil is in the details” made so much sense in this story!


Food for thought

Epoch Semantic Versioning

Read

What if we incremented the major component of semantic versioning to ship "minor" breaking changes? Anthony Fu shares his thoughts on why that could be a good idea.

Supply chain security with mise and asdf plugins

Read

Mise is making security a first-class citizen in the supply chain of development tools. They have officialized many of the existing plugins, and started recommending aqua-registry, which supports advanced supply chain features.

Be aware of the Makefile effect

Read

How many times did you define a new CI pipeline or Fastlane lane by copying over the content of an existing one? William Woodruff coined a new term for that cargo-culting, the Makefile effect, and shared why he thinks minimizing it is a good idea.

It's just verbose

Scroll through

Ben Cohen came across a post by Thomas Ricouard, and took the opportunity to share the many decisions that went into Swift to make it way less verbose than Objective-C. If you like Swift, you'll love this thread.

Announcing Tuist registry

Read

Cold and warm resolution of package dependencies might add up minutes to every CI build. In this blog post we share what it took us to solve that problem and the outcome of that work, a registry for the Swift community.